import JointConfig from "./joint-config";
import Vec3 from "../../common/vec3";
import SpringDamper from "./spring-damper";
import RotationalLimitMotor from "./rotational-limit-motor";
import Method from "../../common/method";

export default class RevoluteJointConfig  extends JointConfig{
    constructor() {
        super();
        this.localAxis1 = new Vec3(1,0,0);
        this.localAxis2 = new Vec3(1,0,0);
        this.springDamper = new SpringDamper();
        this.limitMotor = new RotationalLimitMotor();
    }
    init(rigidBody1,rigidBody2,_worldAnchor,_worldAxis) {
        let worldAnchor=Method.convertVec3(_worldAnchor),worldAxis=Method.convertVec3(_worldAxis).elements;
        this._init(rigidBody1,rigidBody2,worldAnchor);
        Method.inverseTransformVec3(rigidBody1._transform.elements,worldAxis,1,this.localAxis1.elements);
        Method.inverseTransformVec3(rigidBody2._transform.elements,worldAxis,1,this.localAxis2.elements);
        return this;
    }
}